/**
 * Created by 卡西莫多 on 2017/6/6.
 */
import {Injectable} from '@angular/core';
import 'rxjs/add/operator/map';
import {Cart} from "../models/Cart";
import {Dish} from "../models/Dish";
import {Http} from "@angular/http";

import {url_cart as api_url} from '../config';
import {Observable} from "rxjs/Observable";

/*
 Generated class for the DishProvider provider.

 See https://angular.io/docs/ts/latest/guide/dependency-injection.html
 for more info on providers and Angular 2 DI.
 */
@Injectable()
export class CustomerCartProvider {
  public carts: Cart[];

  constructor(public http: Http) {
  }

  getCart(): Observable<Cart[]> {
    return this.http.get(api_url)
      .map(response => response.json().data as Cart[])
  }

  addCart(dish: Dish, num = 1): number {
    return 1;
  }

  delCart(): number {
    return 1;
  }

  updateCart(): boolean {
    return true;
  }

  createOrder(): boolean {
    return false;
  }

}
